import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NcategoryVO, NcategoryForm, NcategoryQuery } from '@/api/nav/ncategory/types';

/**
 * 查询开源分类列表
 * @param query
 * @returns {*}
 */

export const listNcategory = (query?: NcategoryQuery): AxiosPromise<NcategoryVO[]> => {
  return request({
    url: '/nav/ncategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询开源分类详细
 * @param categoryId
 */
export const getNcategory = (categoryId: string | number): AxiosPromise<NcategoryVO> => {
  return request({
    url: '/nav/ncategory/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增开源分类
 * @param data
 */
export const addNcategory = (data: NcategoryForm) => {
  return request({
    url: '/nav/ncategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改开源分类
 * @param data
 */
export const updateNcategory = (data: NcategoryForm) => {
  return request({
    url: '/nav/ncategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除开源分类
 * @param categoryId
 */
export const delNcategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/nav/ncategory/' + categoryId,
    method: 'delete'
  });
};
